{% load static %}
{% load i18n %}

{% comment %}
Template for rendering rows of TestCases. Rows are TR tags used in a TABLE
tag.

Arguments:
- test_cases: an iterable object containing all TestCases. Particularly,
test_cases should be a queryset of a list of TestCases.
- selected_case_ids: used to select loaded cases.
- test_plan: its pk is used here.
{% endcomment %}
{% for test_case in test_cases %}
<tr class="case_title {% cycle 'odd' 'even' %}" id='{{ test_case.pk }}' >
	<td class="expandable js-just-loaded">
		<img class="expand blind_icon" src="{% static 'images/t1.gif' %}" border="0" alt="">
	</td>
	<td>
		{# FIXME: replacing selected_case_ids with selected_cases_ids is proper  #}
		<input type="checkbox" name="case" value="{{ test_case.pk }}"
		class="checkbox case_selector" {% if not selected_case_ids or test_case.pk in selected_case_ids %}checked{% endif %} />
	</td>
	<td>
		<a href="{% url "testcases-get" test_case.case_id %}">{{ test_case.pk }}</a>
	</td>
	<td>
		<a href="{% url "testcases-get" test_case.case_id %}">{{ test_case.summary }}</a>
	</td>
	<td class="col_author_content"><a href="{% url "tcms-profile" test_case.author.username %}">{{ test_case.author }}</a></td>
	<td class="col_author_content">
		{% if test_case.case_status.name == 'CONFIRMED' %} {# Show default tester when confirmed. #}
			{% if test_case.default_tester_id %}<a href="{% url "tcms-profile" test_case.default_tester.username %}">{% endif %}{{ test_case.default_tester }}{% if test_case.default_tester_id %}</a>{% endif %}
		{% else %} {# Show reviewer when not confirmed. #}
			{% if test_case.reviewer_id %}<a href="{% url "tcms-profile" test_case.reviewer.username %}">{% endif %}{{ test_case.reviewer }}{% if test_case.reviewer_id %}</a>{% endif %}</td>
		{% endif %}
	</td>
	<td class="col_tester_content expandable">{{ test_case.is_automated }}</td>

	<td status='{{ test_case.case_status }}'>
		{% if perms.testcases.change_testcase %}
		<select class="change_status_selector js-just-loaded">
			{% for case_stat in case_status %}
			<option {% ifequal case_stat.pk test_case.case_status_id %} selected="1" {% endifequal %} value="{{ case_stat.id }}">{{ case_stat.name }}</option>
			{% endfor %}
		</select>
		{% else %}
		{{ test_case.case_status }}
		{% endif %}
	</td>
	<td class="col_priority_category expandable">{{ test_case.category }}</td>
	<td class="col_priority_content expandable" align="center">{{ test_case.priority }}</td>
	<td valign="top" width="8%" class="col_category_content expandable" style="display:none">{{ test_case.category }}</td>
	<td class="col_sortkey_content" align="center">
		{{ test_case.cal_sortkey }}
	</td>
	<td align="center" >
		{% if perms.testcases.change_testcase %}
		<a class="editlink" href="{% url "testcases-edit" test_case.case_id %}">Edit</a>
		{% else %}
		<span class="editlink grey">{% trans "Edit" %}</span>
		{% endif %}
	</td>
</tr>
<tr class="case_content hide" style="display: none;">
	<td colspan="12">
		<div id="id_loading_{{ test_case.pk }}" class="ajax_loading normal_cases"></div>
	</td>
</tr>
{% empty %}
<tr>
	<td colspan="12">
		<center class="prompt-message prompt">{% trans "No test case was found in this plan." %}</center></span>
	</td>
</tr>
{% endfor %}
